package com.em.controller;

import com.em.dto.UserDTO;
import com.em.entity.User;
import com.em.utils.page.PageResult;
import com.em.utils.page.Result;
import com.em.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户控制层
 *
 * @author exclusive
 * @version 1.0
 */
@Api(tags = "用户管理接口")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 新增用户
     */
    @ApiOperation("新增用户接口")
    @RequestMapping("/addUser")
    public Result<?> addUser(@RequestBody User user) {
        return Result.result(userService.addUser(user));
    }

    /**
     * 获取用户列表
     */
    @ApiOperation("获取用户列表")
    @RequestMapping("/getUserList")
    @ResponseBody
    public Result<PageResult> getUserList(@RequestBody UserDTO dto) {
        return Result.result(userService.getUserList(dto));
    }
}
